using HT.Framework;
using DG.Tweening;
using DG.Tweening;
using UnityEngine;

namespace TG
{
    public class GetPointTextUI : HTBehaviour
    {
        //启用自动化
        protected override bool IsAutomate => true;

        public float offsetY;
        public float duration;

        private TMPro.TextMeshProUGUI m_textMesh;

        private void Awake()
        {
            m_textMesh = GetComponent<TMPro.TextMeshProUGUI>();
        }

        private void Start()
        {
            m_textMesh.DOFade(0f, duration / 2f).SetDelay(duration / 2);

            var targetY = transform.localPosition.y + offsetY;
            transform.DOLocalMoveY(targetY, duration).SetEase(Ease.OutQuart).OnComplete(() => Destroy(gameObject));
        }

        public void SetText(string _text)
        {
            m_textMesh.text = _text;
        }
    }
}
